package com.example.newinfinity.View.DrawShape

import android.graphics.Canvas
import android.graphics.Paint

//画三角形
class TriangleShape() : Shape() {

    override fun setStartPoint(x: Float, y: Float) {
        super.setStartPoint(x, y)
    }

    override fun setEndPoint(x: Float, y: Float) {
        super.setEndPoint(x, y)
    }

    override fun draw(canvas: Canvas) {
        mPath.reset()
        //根据rectF区域来绘制三角形 拉伸操作时可以实时的显示拉伸后的图形
        mPath.moveTo(rectF.left, rectF.bottom)
        mPath.lineTo(rectF.right, rectF.bottom)
        mPath.lineTo((rectF.left + rectF.right)/2, rectF.top)
        mPath.close()
        /*mPath.moveTo(startX, endY)
        mPath.lineTo(endX, endY)
        mPath.lineTo((startX + endX) / 2, startY)*/
        canvas.drawPath(mPath, mPaint)
        //继承父类 拖拉点拽状态为selected时显示边框及四个拖拉圆点
        super.draw(canvas)
    }

    override fun fillColor() {
        //填充时画笔模式修改为fill
        mPaint.style = Paint.Style.FILL
        super.fillColor()
    }

    override fun containsPointInPath(x: Float, y: Float): Boolean {
        return super.containsPointInPath(x, y)
    }
}